<html>
<head><meta charset="utf-8"><title>Implicitly enabled features · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implicitly.20enabled.20features.html">Implicitly enabled features</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="245740834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implicitly%20enabled%20features/near/245740834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alphyr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implicitly.20enabled.20features.html#245740834">(Jul 12 2021 at 20:06)</a>:</h4>
<p>I was reading <a href="https://github.com/rust-lang/reference/blob/master/src/attributes/codegen.md#available-features">the reference about target features</a> and I was surprised that <code>bmi2</code> does not imply <code>bmi1</code>. Is there something I missed ?<br>
And given that all processors supporting <code>bmi2</code> also support <code>bmi1</code> anyway, could we make the former implicitly enable the latter ?</p>
<p>Also, according to <a href="https://en.wikipedia.org/wiki/X86_Bit_manipulation_instruction_set">Wikipedia on BMI</a>:</p>
<blockquote>
<p>Intel considers POPCNT as part of SSE4.2, and LZCNT as part of BMI1</p>
</blockquote>
<p>This is at least true on all CPUs targeted by Rust. Could we enable this implication too ?</p>
<p>(I don't know if this is the right place to ask, please tell me is this conversion belongs somewhere else)</p>



<a name="245743504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implicitly%20enabled%20features/near/245743504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implicitly.20enabled.20features.html#245743504">(Jul 12 2021 at 20:27)</a>:</h4>
<p>Rustc doesn't know anything about target features except for a list of target features that you are allowed to use with <code>#[cfg(target_feature)]</code> or <code>#[target_feature]</code>. <code>-Ctarget-features</code> accepts any target feature supported by the backend (normally LLVM). LLVM probably does handle target feature dependencies, but rustc itself doesn't know anything about those dependencies or any target features that aren't explicitly listed in the source of rustc itself.</p>



<a name="245747144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implicitly%20enabled%20features/near/245747144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alphyr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implicitly.20enabled.20features.html#245747144">(Jul 12 2021 at 20:54)</a>:</h4>
<p>Rustc must have some sense of feature dependencies though, otherwise this kind of things (<a href="https://godbolt.org/z/j3Wvbx1b4">https://godbolt.org/z/j3Wvbx1b4</a>) would not work (knowing that <code>ssse3</code> implies <code>sse3</code>)</p>



<a name="245748798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implicitly%20enabled%20features/near/245748798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implicitly.20enabled.20features.html#245748798">(Jul 12 2021 at 21:03)</a>:</h4>
<p>Oh yeah, it requests the list of enabled freatures from the backend. In this case LLVM. That must mean LLVM doesn't consider bmi2 to depend on bmi1.</p>



<a name="245749174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implicitly%20enabled%20features/near/245749174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implicitly.20enabled.20features.html#245749174">(Jul 12 2021 at 21:04)</a>:</h4>
<p>It requests them from LLVM at <a href="https://github.com/rust-lang/rust/blob/b5a2ccee81406303324016d03399fac68ceb6718/compiler/rustc_codegen_llvm/src/llvm_util.rs#L192">https://github.com/rust-lang/rust/blob/b5a2ccee81406303324016d03399fac68ceb6718/compiler/rustc_codegen_llvm/src/llvm_util.rs#L192</a></p>



<a name="245751741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implicitly%20enabled%20features/near/245751741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alphyr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implicitly.20enabled.20features.html#245751741">(Jul 12 2021 at 21:20)</a>:</h4>
<p>Ok.<br>
And do you have an idea of why doesn't LLVM consider this ?</p>



<a name="245751888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implicitly%20enabled%20features/near/245751888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implicitly.20enabled.20features.html#245751888">(Jul 12 2021 at 21:22)</a>:</h4>
<p>No idea.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>